﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bike.Repository;
using Bike.Common;

namespace Bike.Biz
{
    public class StaffService : BikeService<Staff>
    {
        public override Staff Add(Staff entity)
        {
            entity.Password = SecurityHelper.HashPassword(entity.Password);
            return base.Add(entity);
        }

        public Staff GetAuthenticate(string username, string password)
        {
            string hashedPW = SecurityHelper.HashPassword(password);
            var staff = GetQuery().Where(p => p.Username == username && p.Password == hashedPW).FirstOrDefault();
            return staff;
        }
    }
}
